define(function (require, exports, module) {
	var store = require("store");
	var activeUser = store.get("user");
	var Dialog=require("dialog");
	var aw = require("ajaxwrapper");
	var Form = require("form");
	
    module.exports = {
        grantCard: function(widget){
			var remarkForm =new Form({
				autoRender : false,
        		model:{
					id:"remarkForm",
					defaultButton:false,
					items:[{
						name : "idNumber",
						label : "身份证号",
						validate : ["required"],
					},{
						name : "name",
						label : "姓名",
						validate : ["required"],
					},{
						name  : "cardNumber",
						label : "卡号",
						validate : ["required"],
					},{
						name  : "balance",
						label : "充值金额(元)",
						exValidate: function(value) {
							var reg = /[^\- \d.]/g;
                            if (reg.test(value)) {
                                return "金额必须输入数字且不能为负！";
                            } else {
                                return true;
                            }
                        },
					},{
						name  : "creatDate",
						label : "创建日期",
						defaultValue : moment(new Date()).format("YYYY-MM-DD"),
						type : "date",
						readonly : true,
					}]
				 }
			});
			widget.set("remarkForm",remarkForm);
			Dialog.showComponent(remarkForm,{
				defaultButton:false,
				title: "发卡",
				buttons :[{
					id:"save",
					text:"发卡",
					className:"btn-save",
					handler:function(){
						if(remarkForm.valid()){
							var FormData = remarkForm.getData();
							FormData.servicePoint = widget.get("subnav") .getValue("servicePoint");
							aw.saveOrUpdate("api/cate/consumecard/grantcard",aw.customParam(FormData),function(saveData){
								Dialog.close();
			          			widget.get("grid").refresh();
			       			});
						};
					}
				},{
					id:"close",
					text:"取消",
					handler:function(){
						Dialog.close();
					}
				}]
			});
        }
    };
});
